/// <reference path="./typings/index.d.ts" />
'use strict';

const gulp = require('gulp');
const $ = require('gulp-load-plugins')();
const bsync = require('browser-sync');
const reload = bsync.reload;
const run = require('run-sequence');

gulp.task('sass', function() {
    return $.rubySass('./app/views/public/styles/**/*.scss')
        .pipe($.plumber())
        .pipe(gulp.dest('./app/views/public/styles/'))
        .pipe(reload({
            stream: true,
        }));
});
gulp.task('html', function() {
    gulp.src('./app/views/**/*.html')
        .pipe(reload({
            stream: true,
        }))
});

gulp.task('watch:scss', function() {
    gulp.watch('./app/views/public/styles/**/*.scss', ['sass']);
});
gulp.task('watch:html', function() {
    gulp.watch('./app/views/**/*.html', ['html']);
});
gulp.task('watch', cb => {
    // content
    run(['watch:scss', 'watch:html'], cb)
});
gulp.task('develop', function() {
    $.nodemon({
        script: 'app.js',
        ext: 'js coffee ejs',
        stdout: false
    })
});
gulp.task('browser-sync', function() {
    bsync.init({
        proxy: "127.0.0.1:3000",
        port: 8800
    });
});
gulp.task('default', cb => {
    run(['sass'], ['develop'], ['browser-sync', 'watch'], cb);
});